﻿@model KTD.Web.Models.VD.SalerCD
@{
    ViewBag.Title = "Detail";
}

<style>
    .layui-table th {
        font-weight: bold;
        background-color: #f2f2f2;
        text-align: right;
    }
</style>
@{
    var oldImgRoot = "";
}
<fieldset class="layui-elem-field">
    <legend>基本信息</legend>
    <div class="layui-field-box layui-form">
        <table class="layui-table">
            @Html.HiddenFor(model => model.type)
            <tbody>
                <tr>
                    <th>公司(平台)名称</th>
                    <td> @Html.TextBoxFor(model => model.platform, new { @class = "layui-input" })</td>
                    <th>姓名</th>
                    <td> @Html.TextBoxFor(model => model.name, new { @class = "layui-input" })</td>
                    <th>入驻楼盘</th>
                    <td>  @Html.DropDownListFor(model => model.housename, ViewBag.houseId as IEnumerable<SelectListItem>, new { @class = "layui-input" ,@lay_search=""})</td>
                </tr>
                <tr>
                    <th>手机</th>
                    <td>@Html.TextBoxFor(model => model.tel, new { @class = "layui-input" })</td>
                    <th>微信</th>
                    <td> @Html.TextBoxFor(model => model.wechat, new { @class = "layui-input" })</td>
                    <th>推荐人手机</th>
                    <td> @Html.TextBoxFor(model => model.ptel, new { @class = "layui-input" })</td>
                </tr>
                <tr>
                    <th>浏览量</th>
                    <td> @Html.TextBoxFor(model => model.click, new { @class = "layui-input" })</td>
                    <th>点赞</th>
                    <td> @Html.TextBoxFor(model => model.zan, new { @class = "layui-input" })</td>
                    <th>佣金</th>
                    <td> @Html.TextBoxFor(model => model.money, new { @class = "layui-input" })</td>
                </tr>
                <tr>
                    <th>头像</th>
                    <td><img src="@Model.avatar" />  <input type="file" id="fileAvatar" class="layui-input" /></td>
                    <th>二维码</th>
                    <td><img src="@(oldImgRoot+Model.code)" />  <input type="file" id="fileCode" class="layui-input" /></td>
                    <th>工牌</th>
                    <td><img src="@(oldImgRoot+Model.gp)" />  <input type="file" id="fileGp" class="layui-input" /></td>
                </tr>
            </tbody>
        </table>
        <div class="layui-form-item">
            <label for="L_email" class="layui-form-label" style="width:100px;">
                审核状态
            </label>
            <div class="layui-input-inline">
                @Html.EnumDropDownListFor(model => model.status, new { @class = "layui-input" })

            </div>

            <label for="L_email" class="layui-form-label" style="width:100px;">
                热度
            </label>
            <div class="layui-input-inline">
                @Html.TextBoxFor(model => model.hot, new { @class = "layui_input", type = "number" })

            </div>
            <button id="btnUpdate" class="layui-btn" lay-filter="add" lay-submit="">
                提交
            </button>
        </div>


    </div>
</fieldset>

@section scripts{
    <script>
        layui.use(['form', 'layer'], function () {
            $ = layui.jquery;
            var form = layui.form
                , layer = layui.layer;


            //监听提交
            form.on('submit(add)', function (data) {
                var formdata = new FormData();
                formdata.append("platform", $("#platform").val());
                formdata.append("name", $("#name").val());
                formdata.append("housename", $("#housename").val());
                formdata.append("tel", $("#tel").val());
                formdata.append("wechat", $("#wechat").val());
                formdata.append("tel", $("#tel").val());
                formdata.append("ptel", $("#ptel").val());
                formdata.append("click", $("#click").val());
                formdata.append("zan", $("#zan").val());
                 formdata.append("money", $("#money").val());
                formdata.append("fileAvatar", $("#fileAvatar")[0].files[0]);
                formdata.append("fileCode", $("#fileCode")[0].files[0]);
                formdata.append("fileGp", $("#fileGp")[0].files[0]);
                formdata.append("status", $("#status").val());
                formdata.append("hot", $("#hot").val());
                formdata.append("type", $("#type").val());
                $.ajax({

                    url: "/Saler/Create",
                    type: "post",
                    data: formdata,
                    processData: false,    // 不处理数据
                    contentType: false,    // 不设置内容类型

                    success: function (data) {

                        if (data.success) {
                            layer.alert("新增成功", { icon: 6 }, function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                parent.layer.close(index);
                                parent.window.location.reload();
                            });
                        } else {
                            layer.alert("新增失败！", { icon: 6 });
                        }
                        
                    }
                })
                return false;
            });


        });

    </script>
}